package com.lc.afbx.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lc.afbx.BaseApplication;
import com.lc.afbx.R;
import com.lc.afbx.conn.GetApiRecord;
import com.lc.afbx.util.TimeUtil;

import java.util.List;

/**
 * Created by Administrator on 2016/6/6.
 */
public class RecordAdapter extends BaseAdapter {
    private List<GetApiRecord.Data> data;
    private LayoutInflater inflater;

    public RecordAdapter(Context context, List<GetApiRecord.Data> data) {
        inflater = LayoutInflater.from(context);
        this.data = data;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;

        if (convertView == null) {
            convertView = inflater.inflate(R.layout.item_duihuan_listview, null);
            BaseApplication.ScaleScreenHelper.loadView((ViewGroup) convertView);

            holder = new ViewHolder();

            holder.name = (TextView) convertView.findViewById(R.id.xiangqing);
            holder.jiFen = (TextView) convertView.findViewById(R.id.jifen);
            holder.time = (TextView) convertView.findViewById(R.id.shijian);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.name.setText(data.get(position).goodsname);
        holder.jiFen.setText(data.get(position).integral);
        holder.time.setText(data.get(position).posttime);

        return convertView;
    }

    class ViewHolder {
        TextView name, jiFen, time;
    }
}
